# -*- coding: utf-8 -*-

#    Copyright (C) 2014 by Promotux
#                       di Francesco Meloni snc - http://www.promotux.it/

#    Author: Francesco Meloni  <francesco@promotux.it>

#    This file is part of OdCollect.

#    OdCollect is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 2 of the License, or
#    (at your option) any later version.

#    OdCollect is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with OdCollect.  If not, see <http://www.gnu.org/licenses/>.


from sqlalchemy import *
from Environment import *

t_action = Table('action', meta,
    Column('id', Integer, primary_key=True),
    Column('denominazione_breve', String(25), nullable=False),
    Column('denominazione', String(200), nullable=False),
    schema=mainSchema,
    extend_existing=True
    )
t_action.create(checkfirst=True)


s= select([t_action.c.id]).execute().fetchall()
azioni  = t_action.insert()

if (1,) not in s:
    azioni.execute(id=1, denominazione_breve = "LOGIN", denominazione = "Puo' effettuare il login nell'applicazione")
if (2,) not in s:
    azioni.execute(id=2, denominazione_breve = "SALVA", denominazione = "Puo' effettuare degli inserimenti nell'applicazione")
if (3,) not in s:
    azioni.execute(id=3, denominazione_breve = "MODIFICA", denominazione = "Puo' effettuare delle modifiche ai dati nel Database")
if (4,) not in s:
    azioni.execute(id=4, denominazione_breve = "DELETE", denominazione = "Puo' effettuare delle cancellazioni nel database")
